﻿using System.Security.Claims;
using Microsoft.IdentityModel.Tokens;

namespace housingsafety.server.Filters
{
    /// <summary>
    /// 支持存储的token验证
    /// </summary>
    public class StoreJwtSecurityTokenHandler : ISecurityTokenValidator
    {
        private readonly ISecurityTokenValidator _securityTokenValidator;
        public StoreJwtSecurityTokenHandler(ISecurityTokenValidator securityTokenValidator)
        {
            _securityTokenValidator = securityTokenValidator;
        }

        public bool CanValidateToken => _securityTokenValidator.CanValidateToken;

        public int MaximumTokenSizeInBytes
        {
            get => _securityTokenValidator.MaximumTokenSizeInBytes;
            set => _securityTokenValidator.MaximumTokenSizeInBytes = value;
        }

        public bool CanReadToken(string securityToken)
        {
            return _securityTokenValidator.CanReadToken(securityToken);
        }

        public ClaimsPrincipal ValidateToken(string securityToken, TokenValidationParameters validationParameters, out SecurityToken validatedToken)
        {
            return _securityTokenValidator.ValidateToken(securityToken, validationParameters, out validatedToken);
        }
    }
}


